import delimited basicinfo.csv, delimiter("*") 

gen appy = substr(appdate,1,4)
gen appm = substr(appdate,6,2)
gen appd = substr(appdate,9,2)
gen regy = substr(registerdate,1,4)
gen regm = substr(registerdate,6,2)
gen regd = substr(registerdate,9,2)
destring(appy appm appd regy regm regd), replace 
gen app_date = mdy(appm,appd,appy)
gen reg_date = mdy(regm,regd,regy)

gen regi = 1 if inlist(finaldisposal,"등록결정(심사전치후)","등록결정(일반)","등록결정(재심사후)","등록결정(취소환송후)","심판원에 의한 등록결정","이의신청후 등록유지")
replace regi = 0 if registernum == "" | registernum == " "
replace regi = 0 if regi ==.
bysort registernum regi: gen dup = cond(_N==1,0,_n)
replace regi = 0 if regi == 1 & dup > 0
drop dup

sa basicinfo, replace


